package edu.rht.ui.internal.model.impl;
import java.util.ArrayList;

import org.eclipse.jdt.core.IJavaElement;

import edu.rht.ui.internal.model.ITreeElement;
public class TreeElement implements ITreeElement{
	private ArrayList<IJavaElement> _children=new ArrayList<IJavaElement>();
	private IJavaElement _parent=null;
	private IJavaElement _data=null;

	public Object[] getChildren() {
		return this._children.toArray();
	}

	public void setChildren(ArrayList<Object> children) {
		if(children==null)
			return;
		for(Object obj : children){
			this.addOneChild(obj);
		}
	}

	public void clearAllChildren() {
		this._children.clear();
	}

	public void addOneChild(Object child) {
		if(child instanceof IJavaElement){
			this._children.add((IJavaElement)child);
		}
		else
			this._children.add(null);
	}

	public IJavaElement getParent() {
		return this._parent;
	}

	public void setParent(Object parent) {
		if(parent instanceof IJavaElement)
			this._parent=(IJavaElement)parent;
		else
			this._parent=null;
	}

	public Object getLabel() {
		if(this._data==null)
			return "";
		else
			return this._data.getElementName();
	}

	public int getChildrenCount() {
		return this._children.size();
	}

}
